import java.io.*;

import object.ErrorReporter;


public class maintest {
	  private Scaner scaner;
	  private File testFile;
	  public static final String testFileAdd = "Test-normalInput.txt";  //the location of test file
	  private RandomAccessFile fileReader;
	  public ErrorReporter errorReporter = new ErrorReporter();
	  //function to test file
	  public void Testin() throws Exception
	  { 
		this.scaner =new Scaner();
	    try{
	    	testFile = new File(testFileAdd);
	    	this.fileReader = new RandomAccessFile(testFile,"r");
	       }
	    catch(Exception e)
	      {
	    	System.out.println("No test file exists.");
	      }
	   }
	  public void startAnalyze() throws IOException
	  {
		  String tmpString ="";
		  String result;
		  int row = 0;
		  System.out.println("Analyze Start");
		  try
		  {
			  while((tmpString = this.fileReader.readLine())!=null){
					++row;
					System.out.println("analyze row " + row);
					// System.err.println(tmpString + "!! " +row);
					result = scaner.scan(tmpString,row);
					System.out.println(result);
					scaner.cleanScaner();
					tmpString = "";
				}
			} catch (Exception e) {
				e.printStackTrace();
			}finally{
				scaner.end();
			}
		}

		public static void main(String[] args) 
		{
			maintest a = new maintest();
			try {
				a.Testin();
				a.startAnalyze();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				a.errorReporter.reportWriterCloseError();
			}
		}
}





